package procsim;

import java.awt.*;

public class PaintALU extends PaintTab {
    public PaintALU(Paint parent) {
        super(parent);
        // Coordinates
        Design.ldCONTROL.addCoords(this, Design.ALUAND6.getUpper2Coords(60));
        Design.HALT.addCoords(this, Design.ALUAND6.getLower2Coords(30));
        Design.ALUANDout.addCoords(this, Design.ALUAND6.getResCoords(20));
        Design.halt.addCoords(this, Design.ALURS.getQCoords(20));
        Design.haltCompl.addCoords(this, Design.ALURS.getQComplCoords(20));
        Design.Xout.addCoords(this, Design.ALU.getInACoords(50));
        Design.Yout.addCoords(this, Design.ALU.getInBCoords(50));
        Design.aluODO.addCoords(this, Design.ALUAND1.getUpper2Coords(40));
        Design.ADD.addCoords(this, Design.ALUAND1.getLower2Coords(40));
        Design.aluADD.addCoords(this, Design.ALUAND1.getResCoords(15));
        Design.aluADD.addCoords(this, 205, 119, 205, 127);
        Design.aluADD.addCoords(this, Design.ALU.getAddCoords(15));
        Design.aluODO.addCoords(this, Design.ALUAND2.getUpper2Coords(40));
        Design.AND.addCoords(this, Design.ALUAND2.getLower2Coords(40));
        Design.aluAND.addCoords(this, Design.ALU.getAndCoords(30));
        Design.transX.addCoords(this, Design.ALU.getTransCoords(25));
        Design.C16.addCoords(this, Design.ALU.getCoutCoords(20));
        Design.aluOJO.addCoords(this, Design.ALUAND3.getLower2Coords(40));
        Design.INC.addCoords(this, Design.ALUAND3.getUpper2Coords(40));
        Design.aluINC.addCoords(this, Design.ALUAND3.getResCoords(20));
        Design.aluINC.addCoords(this, 480, 119, 480, 127);
        Design.aluINC.addCoords(this, Design.ALU.getIncCoords(12));
        Design.aluOJO.addCoords(this, Design.ALUAND4.getLower2Coords(40));
        Design.DEC.addCoords(this, Design.ALUAND4.getUpper2Coords(40));
        Design.aluDEC.addCoords(this, Design.ALU.getDecCoords(32));
        Design.aluOJO.addCoords(this, Design.ALUAND5.getLower2Coords(40));
        Design.ASR.addCoords(this, Design.ALUAND5.getUpper2Coords(40));
        Design.aluASR.addCoords(this, Design.ALUAND5.getResCoords(20));
        Design.aluASR.addCoords(this, 480, 178, 480, 171);
        Design.aluASR.addCoords(this, Design.ALU.getAsrCoords(11));
        Design.Fout.addCoords(this, Design.ALU.getResCoords(80));
        Design.ldTEMP.addCoords(this, Design.TEMP.getLdCoords(40));
        Design.TEMPout.addCoords(this, Design.TEMP.getOutCoords(30));
        Design.Fout.addCoords(this, 341, 260, 550, 260);
        Design.Fout.addCoords(this, 550, 260, 550, 299);
        Design.X15.addCoords(this, 600, 270, 600, 299);
        Design.Y15.addCoords(this, 625, 270, 625, 299);
        Design.X0.addCoords(this, 650, 270, 650, 299);
        Design.C16.addCoords(this, 675, 270, 675, 299);
        Design.ADD.addCoords(this, 470, 320, 500, 320);
        Design.INC.addCoords(this, 470, 340, 500, 340);
        Design.DEC.addCoords(this, 470, 360, 500, 360);
        Design.ASR.addCoords(this, 470, 380, 500, 380);
        Design.aluN.addCoords(this, 700, 320, 730, 320);
        Design.aluC.addCoords(this, 700, 340, 730, 340);
        Design.aluV.addCoords(this, 700, 360, 730, 360);
        Design.aluZ.addCoords(this, 700, 380, 730, 380);

        // Collections
        elements.add(Design.ALU);
        elements.add(Design.TEMP);
        elements.add(Design.ALURS);
        elements.add(Design.ALUAND1);
        elements.add(Design.ALUAND2);
        elements.add(Design.ALUAND3);
        elements.add(Design.ALUAND4);
        elements.add(Design.ALUAND5);
        elements.add(Design.ALUAND6);
        elements.add(Design.ALUCE);
        
        lines.add(Design.TEMPout);
        lines.add(Design.ldCONTROL);
        lines.add(Design.HALT);
        lines.add(Design.X15);
        lines.add(Design.Y15);
        lines.add(Design.X0);
        lines.add(Design.C16);
        lines.add(Design.ADD);
        lines.add(Design.AND);
        lines.add(Design.INC);
        lines.add(Design.DEC);
        lines.add(Design.ASR);
        lines.add(Design.aluN);
        lines.add(Design.aluZ);
        lines.add(Design.aluC);
        lines.add(Design.aluV);
        lines.add(Design.Xout);
        lines.add(Design.Yout);
        lines.add(Design.Fout);
        lines.add(Design.aluOJO);
        lines.add(Design.aluODO);
        lines.add(Design.aluADD);
        lines.add(Design.aluAND);
        lines.add(Design.aluINC);
        lines.add(Design.aluDEC);
        lines.add(Design.aluASR);
        lines.add(Design.transX);
        lines.add(Design.halt);
        lines.add(Design.haltCompl);
        lines.add(Design.ldTEMP);
        lines.add(Design.ALUANDout);

        addMouseListener(Design.ALUCE);
    }
    @Override
    public void paint(Graphics g){
        super.paint(g);
        Graphics2D gnew = (Graphics2D)g;
        Util.saveGraphics(gnew);
        gnew.setColor(Color.BLACK);
        gnew.drawLine(182, 351, 201, 351);
        Util.restoreGraphics(gnew);
    }
}
